package com.hancher.demo;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.hancher.plugins.hrcontribution.HrContributionConfig;
import com.hancher.plugins.hrcontribution.HrContributionItem;
import com.hancher.plugins.hrcontribution.HrContributionView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -182);
        List<HrContributionItem> data = new ArrayList<>();
        for (int i = 0; i < 182; i++) {
            data.add(new HrContributionItem(calendar.getTime(), i % 2));
            calendar.add(Calendar.DAY_OF_MONTH, 1);
        }

        HrContributionConfig config = new HrContributionConfig()
                .setBorderWidth(2)
                .setBorderColor(-6381922)
                .setItemRound(5)
                .setMonths(new String[]{"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"})
                .setPadding(4)
                .setRank(new int[]{0, 1})
                .setRankColor(new int[]{-1315344, -12490271})
                .setWeeks(new String[]{"周一", "", "周三", "", "周五", "", "周天"})
                .setStartOfWeek(Calendar.MONDAY)
                .setTxtColor(-6381922);

        HrContributionView contributionView = findViewById(R.id.contribution_view);
        contributionView.setData(data.get(0).getTime(), data, config);
    }
}